<template>
  <view class="row" style="justify-content: flex-end; margin: 36rpx 0 50rpx">
    <view>
      <up-text color="#999" text="还有"></up-text>
    </view>
    <view>
      <up-count-down :time="time" format="HH:mm:ss" @change="onChange" ref="countDown">
        <view class="row">
          <up-text type="" color="#EC8093" margin="0 0 0 4rpx"
            :text="`${timeData.hours > 10 ? timeData.hours : '0' + timeData.hours}:`"
            v-if="timeData.hours > 0"></up-text>
          <up-text type="" color="#EC8093"
            :text="`${timeData.minutes > 10 ? timeData.minutes : '0' + timeData.minutes}:`"
            v-if="timeData.minutes > 0"></up-text>
          <up-text type="" color="#EC8093" margin="0 4rpx 0 0" :text="timeData.seconds"></up-text>
        </view>
      </up-count-down>
    </view>
    <view>
      <up-text color="#999" text="订单关闭"></up-text>
    </view>
  </view>
</template>

<script>
import dayjs from 'dayjs';
export default {
  props: {
    createTime: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      time: 0,
      timeData: {},
    }
  },
  mounted() {
    console.log(this.createTime);
    const goalTime = dayjs(this.createTime).add(1, 'day').valueOf();
    const unix = goalTime - dayjs().valueOf();
    this.time = unix > 0 ? unix : 0;
    this.$refs.countDown.start();
  },
  methods: {
    onChange(e) {
      this.timeData = e
    }
  }
}
</script>

<style lang="scss" scoped>

</style>